xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

Python errors All In One

Python errors All In One

errors ❌

  1. from: can't read /var/mail/gpiozero

https://stackoverflow.com/questions/16069816/getting-python-error-from-cant-read-var-mail-bio

  1. SyntaxError: Non-ASCII character '\xe6' in file ./test.py on line 32, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

image

http://python.org/dev/peps/pep-0263/

Pyhton 2 不支持中文emoji

  1. 接收命令行参数 error ❌
  • sys

  • argparse

  • shell script

  • tensorflow

  • getopt

https://www.cnblogs.com/xgqfrms/p/17273858.html

  1. 类型转换 error ❌

https://www.cnblogs.com/xgqfrms/p/17273620.html

demos

#!/usr/bin/env python

# coding: utf8

from gpiozero import LED
from time import sleep

led = LED(12)
# Change 12 to your GPIO pin

# block comments
"""
led.on()
sleep(3)
led.off()
"""

def run(time):
 led.on()
 sleep(time)
 led.off()

def init(n):
 i = 0
 while i < n:
  print(i)
  i += 1
  sleep(1)
  run(1)

# python 接收命令行参数❓
init(7)


bugs

  1. UTF8

# -*- coding: UTF-8 -*-
# coding: utf8
# coding: UTF-8

Unicode & 中文

#!/usr/bin/python
# -*- coding: UTF-8 -*-

# UTF8 Emoji zh-Hans Test

if(1 < "3"):
    print "ok ✅ 正确"
else:
    print "bug ❌ 错误"

#!/usr/bin/python
# coding: utf8
# coding: UTF-8

# UTF8 Emoji zh-Hans Test

if(1 < "3"):
    print "ok ✅ 正确"
else:
    print "bug ❌ 错误"

  1. 类型转换

string to int

#!/usr/bin/env python

# coding: utf8


import sys

# arg1 = sys.argv[1]

from gpiozero import LED
from time import sleep

led = LED(12)
# Change 12 to your GPIO pin

# order, import fisrt
arg1 = sys.argv[1]

print("arg1 =" + arg1)

# block comments
"""
led.on()
sleep(3)
led.off()
"""

def run(time):
 led.on()
 sleep(time)
 led.off()

def init(n):
 i = 0
 while i < n:
  print(i)
  i += 1
  sleep(1)
  run(1)

# python command line args
# init(7)
init(arg1)



refs



©xgqfrms 2012-2021

www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!


posted @   xgqfrms  阅读(11)  评论(13编辑  收藏  举报
相关博文:
阅读排行:
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
历史上的今天:
2022-03-29 Linux bash shell script batch download files All In One
2022-03-29 how to tell whether website visitors from the mobile browser environment in js All In One
2022-03-29 Swift 数据类型 All In One
2022-03-29 Apple SF Symbols All In One
2021-03-29 页面超过 10 分钟没有任何操作
2021-03-29 node.js ECONNRESET error
2020-03-29 ROI
点击右上角即可分享
微信分享提示