我是python的新手,正在为我的工作功能学习python。我遵循一个非常基本的初学者教程,其中大部分看起来非常熟悉,与我使用的其他语言相似。但是当我做非常简单的事情
print( hello world )
我得到了预期的回复
hello world
但当我做另一项简单的任务时:
x = 5
print( x is , x)
我得到:
( x is , 5)
print命令保留了括号和单引号,就我个人而言,我不知道为什么。
我是python的新手,正在为我的工作功能学习python。我遵循一个非常基本的初学者教程,其中大部分看起来非常熟悉,与我使用的其他语言相似。但是当我做非常简单的事情
print( hello world )
我得到了预期的回复
hello world
但当我做另一项简单的任务时:
x = 5
print( x is , x)
我得到:
( x is , 5)
print命令保留了括号和单引号,就我个人而言,我不知道为什么。
由于您使用的是Python2.6,print
是一个语句,而不是一个函数。因此,参数不应该在括号中(请注意,这在3.0版本中发生了更改)。
此代码将执行您想要执行的操作:
print x is , x
您的原始代码实际上创建了一个元组并将其打印出来。
print语句的使用是将类型回显为字符串(x,1)
是一个元组。
In 2.6, if I needed to accept input that allowed a percent sign (such as "foo % bar"), I used raw_input() which worked as expected. In 3.0, input() accomplishes that same (with raw_input() having ...
I need to install mysql-python under python2.6. mysql-python package needs python2.6-devel package that depends on the libpython2.6.so.1.0(64bit) I found on the net some python2.6-devel packages, but ...
Python 3 has a string method called str.isidentifier How can I get similar functionality in Python 2.6, short of rewriting my own regex, etc.?
What is the difference between , and as in except statements, eg: try: pass except Exception, exception: pass and: try: pass except Exception as exception: pass Is the second ...
I have that file structure- BlogDataObjectsUser.py Blogindex.py I want to import the function(say_hello) at User.py from index.py. I am trying this code - from Blog.DataObjects.User import ...
I am trying to make an HTTP request in Python 2.6.4, using the urllib module. Is there any way to set the request headers? I am sure that this is possible using urllib2, but I would prefer to use ...
I just noticed that I cannot use the Python 2.6 dll anymore. Python 2.5 works just fine. import ctypes py1 = ctypes.cdll.python25 py2 = ctypes.cdll.python26 # ctypes.cdll.LoadLibrary("libpython2.6....
I just noticed that my old codes written in python 2.5 does not work now. I am in python 2.6 btw. >>> os.spawnl(os.P_NOWAIT,"setup.exe") Traceback (most recent call last): File "<stdin&...