设为首页
收藏本站
首页
Portal
社区
BBS
活动
模型
圈子
Group
创客工具
查询
登录
每日签到
创客帮-青少年创客创意社区
»
社区
›
圈子
›
程序设计
›
Scratch
›
牛首少儿编程培训群
›
Python学习第一天-变量和字符串(上)
返回列表
发新帖
Python学习第一天-变量和字符串(上)
[复制链接]
15271953841
发表于 2024-1-25 22:00:05
|
显示全部楼层
|
阅读模式
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要
登录
才可以下载或查看,没有账号?
注册
×
Python 3.12.1 (tags/v3.12.1:2305ca5, Dec 7 2023, 22:03:25) [MSC v.1937 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>>x=3
>>>print(x)
3
>>>loveyou1314=1314
>>>520baby=520
SyntaxError: invalid decimal literal
(变量名不能有数字开头)
>>>幸运数=588
>>>print(幸运数)
588
>>>name="小甲鱼"
>>>print(name)
小甲鱼
>>>name="老乌龟"
>>>print(name)
老乌龟
>>>x=3
>>>y=5
>>>y=x
>>>print(y)
3
>>>x=y=3
>>>x
3
>>>y
3
>>>x=3
>>>y=5
>>>z=x
>>>x=y
>>>y=z
>>>print(x,y)
5 3
x=3
y=5
x,y=y,x
>>>print(x,y)
5 3
>>>print('I love China,')
I love China,
>>>print("I love fishC.")
I love fishC.
>>>print('Let's go.')
SyntaxError: unterminated string literal (detected at line 1)
(中间的单引号和两侧的单引号混淆)
>>>print("Let's go.")
Let's go.
>>>print('"Life is short,let's learn Python."')
SyntaxError: unterminated string literal (detected at line 1)
(中间的单引号和两侧的单引号混淆,两侧的双引号只起强调作用)
>>>print('\"Life is short,let\'s learn Python.\"')
"Life is short,let's learn Python."
>>>print('I love China.\nI love fishC.')
( 增加了3个转义字符\’)
I love China.
I love fishC.
(
加了一个转义字符换行\n)
回复
使用道具
举报
提升卡
置顶卡
沉默卡
喧嚣卡
变色卡
千斤顶
显身卡
返回列表
发新帖
QQ客服
返回顶部
快速回复
返回顶部
返回列表