Day4 built-in function supplement, adorner

Source: Internet
Author: User

Li = [11,22,33,44]
def f1 (ARG):
Arg.append (55)
#函数默认返回值None, the function argument is passed a reference
Li = F1 (LI)
Print (LI)
Built-in function supplement: Determine if it is called

Def f1 ():

Pass

Print (callable (F1))

ASCII code and digital conversion
#数字转换为ASCII码
r = Chr (65)
Print (R)
#ASCII转换为数字
n = Ord (' a ')
Print (n)
Random Verification Code
Import Random
List_temp =[]
For I in range (10):
R = Random.randrange (0,10)
if r = = 2 or R = = 4 or R = = 9:
num = Random.randrange (0, 10)
List_temp.append (num)
Else
temp = Random.randrange (65, 91)
c = Chr (temp)
List_temp.append (c)
result = "". Join (List_temp)
Print (Result)
Compile, execute
s = "Print (123)"
#编译: Single, eval (expression), exec (compiled into Python)
#将字符串编译成python代码
R = Compile (s, "<string>", "exec")
#exec执行python代码, no return value
EXEC (R)
#eval只执行表达式, there are return results
box = "8 * 8"
ret = eval (box)
Print (ret)

Day4 built-in function supplement, adorner

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.