substr

python的常见的内置函数

二次信任 提交于 2020-01-24 02:17:16
python的常见的内置函数 内置参数详解 https://docs.python.org/3/library/functions.html?highlight=built#ascii 详细解释:https://www.runoob.com/python/python-built-in-functions.html https://www.runoob.com/python3/python3-built-in-functions.html 1.数学运算函数 abs(x)  此函数返回数字的绝对值。 >>> a=5 >>> abs(a) 5 >>> b = -5 >>> abs(b) 5 divmod(x,y)  函数把除数和余数运算结果结合起来,返回一个包含商和余数的元组 >>> divmod(8,2) (4, 0) >>> divmod(7,2) (3, 1) >>> divmod(9,2) (4, 1) >>> divmod(9,4) (2, 1) pow(x,y,z)  函数是计算x的y次方,如果z在存在,则再对结果进行取模,其结果等效于pow(x,y) %z >>> pow(2,3) 8 >>> pow(3,3) 27 >>> pow(3,3,5) #首先3的3次幂 然后除以5取余数 2 >>> pow(2,3,5) 3 round(x)  返回浮点数x的四舍五入值。 >>

【算法】Substring with Concatenation of All Words 所有单词链接而成的子串

主宰稳场 提交于 2020-01-23 16:03:10
【算法】Substring with Concatenation of All Words 所有单词链接而成的子串 题目 解题思路 代码实现 题目 You are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of substring(s) in s that is a concatenation of each word in words exactly once and without any intervening characters. Example 1: Input: s = “barfoothefoobarman”, words = [“foo”,“bar”] Output: [0,9] Explanation: Substrings starting at index 0 and 9 are “barfoo” and “foobar” respectively. The output order does not matter, returning [9,0] is fine too. Example 2: Input: s = “wordgoodgoodgoodbestword”, words = [

php 生成全世界唯一订单号

时光怂恿深爱的人放手 提交于 2020-01-22 23:17:55
function order_no() { return substr(date('Ymd') . substr(implode(NULL, array_map('ord', str_split(substr(uniqid(), 7, 13), 1))), 0, 8), 4, 16); } 用uniqid获取一个基于当前的微秒数生成的唯一不重复的字符串(但是他的前7位貌似很久才会发生变动,所以不用考虑可删除),取其第8到13位。但是这个字符串里面有英文字母,咋办? 用ord获取他的ASCII码,所以就有了下一步:用str_split把这个字符串分割为数组,用array_map去操作(速度快点)。 然后返回的还是一个数组,KO,在用implode弄成字符串,但是字符长度不定,取前固定的几位,然后前面加上当前的年份和日期,这个方法生成的订单号,全世界不会有多少重复的。 当然,除非你把服务器时间往前调,但是调也不用怕,哥不相信他会在同一微秒内下两次订单,网络数据传输也要点时间的,即便你是在本地。 来源: CSDN 作者: qq_40434718 链接: https://blog.csdn.net/qq_40434718/article/details/103933256

C++中substr函数的用法

别等时光非礼了梦想. 提交于 2020-01-22 21:04:59
std::string::substr string substr (size_t pos = 0, size_t len = npos) const; Generate substring Returns a newly constructed string object with its value initialized to a copy of a substring of this object. The substring is the portion of the object that starts at character position pos and spans len characters (or until the end of the string, whichever comes first). Parameters pos Position of the first character to be copied as a substring. If this is equal to the string length , the function returns an empty string. If this is greater than the string length , it throws out_of_range. Note: The

Replacing Email Domains

▼魔方 西西 提交于 2020-01-22 02:07:27
问题 I'm trying to change the inputted domain name to a new domain name, for example, "hotmail.com" becomes "outlook.com". I believe I'm on the right track, just my substring is off. CREATE OR REPLACE PROCEDURE PR_ChangeDomain (P_Email_Address varchar2) IS Cursor C_Email IS Select Email_Address, Broker_Number From Customer Where Email_Address = P_Email_Address; V_Email varchar2(50); BEGIN Open C_Email; Fetch C_Email into V_Email; While C_Email%FOUND LOOP Update Customer Set Email_Address = SUBSTR(

sqli lab5-6

我的未来我决定 提交于 2020-01-22 00:07:12
left()函数: left(database(),1)=‘s’ left(a,b)从左侧截取a的前b位,正确则返回1,错误则返回0 select left(database(),1)=‘s’; 前1位是否是s regexp函数:select user() regexp ‘r’ user()的结果是root,regexp为匹配root的正则表达式 like函数: select user() like ‘ro%’ 匹配与regexp相似。 substr(a,b,c) select substr() XXXX substr(a,b,c)从位置b开始,截取a字符串c位长度 ascii() 将某个字符串转化为ascii值 select ascii(substr((select database()),1,1)); 直接回显115 或者是: select ascii(substr((select database()),1,1)) > 110; 如果大于110,就会返回1,否则返回0. 6. chr(数字) 或者是ord(‘字母’) 使用python中的两个函数可以判断当前的ascii值是多少 对于security数据库: Less-05 猜列有3列 猜数据库 方法一 http://192.168.50.254/sqli/Less-5/?id=1'and left((select

PAT (Advanced Level) 1016 Phone Bills

可紊 提交于 2020-01-21 00:24:03
题解 模拟。注意美元和美分的转换。如果一个人没有完整的消费记录什么都别输出 (呕~~) :)。 代码 #include<bits/stdc++.h> using namespace std; struct node { string time,flag,other_time; int cost_sec,cost_money; node(string b,string c) {time=b;flag=c;} }; struct info { string name,time,flag; info(string a,string b,string c) {name=a;time=b;flag=c;} bool operator < (const info &n) const {return time<n.time;} }; void modify(string start_time,string end_time,int &sec,int &money); int change_time(string s); int cal_money(int d,int h,int m); int w_time[30]; map<string,vector<node> > smapv; vector<info> info_v; int main() { int i,n; string name

LeetCode All in One 题目讲解汇总(持续更新中...)

倾然丶 夕夏残阳落幕 提交于 2020-01-20 08:55:52
Given a pattern and a string str , find if str follows the same pattern. Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty substring in str . Example 1: Input: pattern = "abab", str = "redblueredblue" Output: true Example 2: Input: pattern = pattern = "aaaa", str = "asdasdasdasd" Output: true Example 3: Input: pattern = "aabb", str = "xyzabcxzyabc" Output: false Notes: You may assume both pattern and str contains only lowercase letters. 这道题是之前那道 Word Pattern 的拓展,之前那道题词语之间都有空格隔开,这样我们可以一个单词一个单词的读入,然后来判断是否符合给定的特征,而这道题没有空格了,那么难度就大大的增加了

php problem: strpos function not working

好久不见. 提交于 2020-01-20 08:08:48
问题 why is the following php code not working: $string = "123"; $search = "123"; if(strpos($string,$search)) { echo "found"; }else{ echo "not found"; } as $search is in $string - shouldn't it be triggered as found? 回答1: This is mentioned in the Manual: strpos() This function may return Boolean FALSE, but may also return a non-Boolean value which evaluates to FALSE, such as 0 or "". Please read the section on Booleans for more information. Use the === operator for testing the return value of this

POJ 2255 题解

元气小坏坏 提交于 2020-01-20 00:56:26
POJ 2255 题解 原题地址 AC代码 题解和题目思路 原题地址 这是地址 AC代码 #include < iostream > #include < algorithm > #include < string > #include < utility > using namespace std ; int find ( char n , string x ) { for ( int i = 0 ; i < x . length ( ) ; ++ i ) { if ( n == x [ i ] ) return i ; } return - 1 ; } class node { public : char data ; node * left ; node * right ; } ; node * generate ( string a , string b ) { node * ptr = new node ; int index = find ( a [ 0 ] , b ) ; ptr - > data = a [ 0 ] ; if ( a . length ( ) == 1 ) { ptr - > right = ptr - > left = NULL ; } else if ( a . length ( ) == 2 ) { if ( index == 1 ) {