会员
周边
新闻
博问
闪存
众包
赞助商
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
fxy-blog
博客园
首页
新随笔
联系
订阅
管理
2022年8月2日
while循环计数问题
摘要: 3局猜拳游戏 count = 0 while count < 3: num = random.randint(0, 2) guess = int(input('请输入剪刀(0),石头(1),布(2):')) count += 1 if guess == num: print('%dvs%d,平局'
阅读全文
posted @ 2022-08-02 10:27 双子叶杂草
阅读(121)
评论(0)
推荐(0)
2022年7月29日
input函数输入默认数据类型为str,由此需要注意的一些问题
摘要: num = random.randint(1, 20) print(num) guess = input('请输入猜的数字:') if guess == num: print('你猜对了') 输入和随机数相同的数,没有显示'你猜对了'。这是因为random随机出来的数是int,input输入的数据都
阅读全文
posted @ 2022-07-29 12:01 双子叶杂草
阅读(484)
评论(0)
推荐(0)
2022年7月27日
python使用input输入字符串报错SyntaxError: invalid syntax
摘要: 使用input函数: userName = input('请输入用户名:') print(type(userName)) 当输入整形或浮点型时,可以正常运行,输入字符串时会报以下错误: 请输入用户名:杂草 Traceback (most recent call last): File "D:/pyt
阅读全文
posted @ 2022-07-27 18:31 双子叶杂草
阅读(2746)
评论(0)
推荐(0)
python中出现 "Non-ASCII character"错误
摘要: 如上图,变量类型为字符串时,print输出会出错。 python中出现 "Non-ASCII character"错误一般是编码问题,Python默认是以ASCII作为编码方式的,如果在Python源码中包含了中文,需要在源码的第一行添加以下语句: # coding=utf-8 并在设置-编辑器-文
阅读全文
posted @ 2022-07-27 17:43 双子叶杂草
阅读(3428)
评论(0)
推荐(0)
公告