[英]Working in PyDev console , But not when running in eclipse
I am learning python with PythonCook Book. 我正在用PythonCook Book学习python。 I came across a scenario and i dont know why this happens. 我遇到了一个场景,我不知道为什么会这样。 The below code is working fine when i run it in PyDev console. 当我在PyDev控制台中运行以下代码时,它工作正常。
>>> user_record =('Dave', 'dave@example.com', '773-555-1212', '847-555-1212')
>>> name, email, *phone_numbers = user_record
>>> name
'Dave'
>>> email
'dave@example.com'
>>> phone_numbers
['773-555-1212', '847-555-1212']
But when i run the code in Eclipse , i get the following error like 'undefined variable name' 但是,当我在Eclipse中运行代码时,出现以下错误,例如“未定义的变量名称”
Whats the concept here ? 这里的概念是什么? i am really new to python 我对python真的很陌生
This is the file I ran. 这是我运行的文件。 It works. 有用。 I don't know why it is giving you an error unless you put ">>>" in the file. 我不知道为什么它会给您一个错误,除非您在文件中输入“ >>>”。
def main():
user_record = ('Dave', 'dave@example.com', '773-555-1212', '847-555-1212')
name, email, *phone_numbers = user_record
print(name)
print(email)
print(phone_numbers)
# end main
if __name__ == "__main__":
main()
output: 输出:
Dave
dave@example.com
['773-555-1212', '847-555-1212']
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.