vendredi 1 juillet 2016

Execute instructions but don't show it in compiling


[non-solved] Hey there, I have made a program which gets the stock rate from a website and then tell the user about the stock rate of the user asked stock. The problem i am encountering is that when i run the program it runs perfectly fine, but i want that some instructions to compile, but i don't want them to show output(I want their output to be hidden) Here's my code:-

import re
import urllib.request
url = "https://www.google.com/finance?q="
stock_name = input("Enter the name of Stock you wanna know: ")
url = url + stock_name
Web =urllib.request.urlopen(url).read()
Web_code = Web.decode('UTF-8')
print(Web_code)
string = re.search('<meta itemprop="price"', Web_code)
start = string.start()
end = start + 50
string_cut = Web_code[start:end]
print(string_cut)

string2 = re.search('content="', string_cut)
start = string2.end()
string_cut2 = string_cut[start:]
print(string_cut2)

string3 = re.search('/', string_cut2)
end = string3.end() - 3
string_cut3 = string_cut2[0:end]
print(string_cut3)

print("The current stock rate of " +stock_name + " is " + string_cut3)

In this code i want to hide the output of everything except the 'input' statement, and the last 'print' statement. And i am using Python 3 and IDE is pycharm


Aucun commentaire:

Enregistrer un commentaire