Divided Land Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 56 Accepted Submission(s): 27 Problem Description It’s time to fight the local despots and redistribute the land. There is a r
1 name = "吴彦祖" 2 for i in name: 3 i_by = bytes(i, encoding = "utf-8") 4 for i_bin in i_by: 5 i_b = bin(i_bin) 6 print(i_b) 输出结果: 0b10110100 0b10100110 0b10010110 我们来详细解读每个转换步骤:for i in name: 通过for循环获取所有的字符i,共获取了3个字符 i_by = bytes(i, enc
Problem Description Given an positive integer A (1 <= A <= 100), output the lowest bit of A. For example, given A = 26, we can write A in binary form as 11010, so the lowest bit of A is 10, so the output should be 2. Another example goes like this:
格式化输出:format() format():把传统的%替换为{}来实现格式化输出 使用位置参数:就是在字符串中把需要输出的变量值用{}来代替,然后用format()来修改使之成为想要的字符串,位置参数就是把传统的%改为{},按照位置顺序自动进行替换 'My name is {},age:{}'.format('Anxc',18) 'My name is Anxc,age:18' 2.使用位置参数:在原有基础上,通过位置的改变来让替换的值根据位置改变(自我感觉没什么用,还不如第一个好用) 'M