sokaoti.com
咪咕文化科技有限公司11月招聘面试题191道2020119

使用re.match函数进行正则表达式匹配时,如果指定的匹配选项中包括re.MULTILINE,则会对每一行开头的若干字符作匹配。()

此题为判断题(对,错)。


正确答案:错误


请编写一个函数int pattern_index(char substr[],char str[]),该函数执行含通配符“?”的字符串的查找时,该通配符可以与任一个字符匹配成功。当子串substr在str中匹配查找成功时,返回子串substr在str中的位置,否则返回值为0。要求使用 for循环实现。输出结果如下:

子串起始位置:5

注意:部分源程序已存在文件test20_2.cpp中。

请勿修改主函数main和其他函数中的任何内容,仅在函数pattern_index的花括号中填写若干语句。

文件test20_2.cpp的内容如下:

include<iostream.h>

int pattern_index(char substr[],char str[])

{

}

void main ( )

{

char *substring,*string;

int same;

substring="???gram";

string="this program return index of substring";

same=pattern_index(substring, string);

if(same)

cout<<"子串起始位置: "<<same<<end1;

else

cout<<"匹配不成功" <<end1;

}


正确答案:int pattern_index(char substr[]char str[]) { int ijk; for(i=0;str[i];i++) for(j=ik=0;(str[j]==substr[k])||(substr[k]=='?');j++k++) if(!substr[k+1]) return(i); return(0); }
int pattern_index(char substr[],char str[]) { int i,j,k; for(i=0;str[i];i++) for(j=i,k=0;(str[j]==substr[k])||(substr[k]=='?');j++,k++) if(!substr[k+1]) return(i); return(0); } 解析:本题主要考查的是考生使用for循环和一维数组的综合能力。对于复杂查找,往往使用for的多重循环,注意里层for循环用来查找字符串的使用


在Shell变量引用操作符可实现模式匹配替换其中()用来的含义是若pattern匹配变量stra的头部,则删除最长匹配部分并返回剩余部分。

A.${strapattern}

B.${strapattern}

C.${stra%pattern}

D.${stra%%pattern}


正确答案:B


正则表达式模块re的match()方法是从字符串的开始匹配特定模式,而search()方法是在整个字符串中寻找模式,这两个方法如果匹配成功则返回match对象,匹配失败则返回空值None。

此题为判断题(对,错)。


正确答案:√


YouhaveanewITmanagerthathasmandatedthatallJSPsmustberefactoredtoincludenoscritpletcode.TheITmanagerhasaskedyoutoenforcethis.Whichdeploymentdescriptorelementwillsatisfythisconstraint?()

A.<jsp-property-group>.<url-pattern>*.jsp</url-pattern>.<permit-scripting>false</permit-scripting>.</jsp-property-group>

B.<jsp-config>.<url-pattern>*.jsp</url-pattern><permit-scripting>false</permit-scripting>.</jsp-config>

C.<jsp-config>.<url-pattern>*.jsp</url-pattern>.<scripting-invalid>true</scripting-invalid>.</jsp-config>

D.<jsp-property-group>.<url-pattern>*.jsp</url-pattern>.<scripting-invalid>true</scripting-invalid>.</jsp-property-group>


参考答案:D


咪咕文化科技有限公司11月招聘面试题面试题面试官常问到的一些题目整理如下:问题 Q1:Python里面match()和search()的区别?可用的回答 :re模块中match(pattern,string,flags),检查string的开头是否与pattern匹配。re模块中research(pattern,string,flags),在string搜索pattern的第一个匹配值。问题 Q2:Python里面match()和search()的区别?可用的回答 :re模块中match(pattern,string,flags),检查string的开头是否与pattern匹配。re模块中research(pattern,string,flags),在string搜索pattern的第一个匹配值。问题 Q3:遇到过得反爬虫策略以及解决方法?可用的回答 : 反爬虫策略: 1.通过headers反爬虫 2.基于用户行为的发爬虫(同一IP短时间内访问的频率,封IP) 3.动态网页反爬虫(通过ajax请求数据,或者通过JavaScript生成) 4.对部分数据进行加密处理的(数据是乱码) 解决方法: 1. 对于基本网页的抓取可以自定义headers,添加headers的数据 2. 使用多个代理ip进行抓取或者设置抓取的频率降低一些, 3. 动态网页的可以使用selenium + phantomjs 进行抓取 4. 对部分数据进行加密的,可以使用selenium进行截图,使用python自带的pytesseract库进行识别,但是比较慢最直接的方法是找到加密的方法进行逆向推理。 问题 Q4:用尽量多的方法实现单例模式?可用的回答 : 一、模块单例 Python 的模块就是天然的单例模式,因为模块在第一次导入时,会生成.pyc文件,当第二次导入时,就会直接加载.pyc文件,而不会再次执行模块代码。 二、静态变量方法 先执行了类的_new_方法(我们没写时,默认调用object._new_),实例化对象; 然后再执行类的_init_方法,对这个对象进行初始化,所有我们可以基于这个,实现单例模式。 class Singleton(object): def _new_(cls,a): if not hasattr(cls, _instance): cls._instance = object._new_(cls) return cls._instance def _init_(self,a): self.a = a 问题 Q5:遇到反爬机制怎么处理?可用的回答 : 反爬机制: headers方向 判断User-Agent、判断Referer、判断Cookie。 将浏览器的headers信息全部添加进去 注意:Accept-Encoding;gzip,deflate需要注释掉 问题 Q6:一行代码实现1-100之和?可用的回答 :使用sum函数。sum(range(1, 101)问题 Q7:参数如何通过值或引用传递?可用的回答 :Python中的所有内容都是一个对象,所有变量都包含对象的引用问题 Q8:有哪些工具可以帮助查找错误或执行静态分析?可用的回答 : PyChecker是一个静态分析工具,可以检测Python源代码中的错误,并警告错误的风格和复杂性。 Pylint是另一种验证模块是否符合编码标准的工具。 auto-pep8工具也可以进行静态代码检查 问题 Q9:def func(a,b=) 这种写法有什么坑?可用的回答 : def func(a,b=): b.append(a) print(b) func(1) func(1) func(1) func(1) 如:看下结果 1 1, 1 1, 1, 1 1, 1, 1, 1 函数的第二个默认参数是一个list,当第一次执行的时候实例化了一个list,第二次执行还是用第一次执行的时候实例化的地址存储, 所以三次执行的结果就是 1, 1, 1 ,想每次执行只输出1 ,默认参数应该设置为None。 问题 Q10:如何在python中使用三元运算符?可用的回答 :三元运算符是用于显示条件语句的运算符。这包含true或false值,并且必须为其评估语句。其基本语法为:三元运算符是用于显示条件语句的运算符。这包含true或false值,并且必须为其评估语句。其基本语法为:on_true if expression else on_false算法题面试官常问到的一些算法题目整理如下(大概率会机考):算题题 A1:组团的变位词题目描述如下:Given an array of strings, group anagrams together.Example:Input: eat, tea, tan, ate, nat, bat,Output: ate,eat,tea, nat,tan, batNote:All inputs will be in lowercase.The order of your output does not matter.给一组带有字符串的数组,进行变位词分类。思路是排序的思路,排序后为同一个的放到一起。效率就测试来看尚可。beat 70%测试地址:https:/ Solution(object): def groupAnagrams(self, strs): :type strs: Liststr :rtype: ListListstr result = for i in strs: key = .join(sorte

String与StringBuffer的区别,以及"+"与append的区别?


正确答案:
         


本程序的功能是,根据用户输入的文件名,在相应的文件内容中查找匹配给定模式的字符串,并将这些字符串显示出来。模式串为“href="…"”。请填写横线处的内容。

注意:请勿改动main()主方法和其他已有语句内容,仅在横线处填入适当语句。

import java.io.*;

import java.util.regex.*;

import javax.swing.*;

public class Example2_10

{

public static void main(String [] argv)

{

final String patternString =

"href\\s*=\\s*(\"[^\"]*\"|[^\\s>])\\s*;

String fileName ;

try

{

System. out. print ( "请输入html 文件的文件名: ");

InputStreamReader in = new InputStreamReader(System.in);

BufferedReader imput = new BufferedReader(in);

fileName = imput.readLine();

if(fileName.equals(" "))

return;

StringBuffer buffer = new StringBuffer();

File file = new File(fileName);

FileInputStream readfile = new FileInputStream(file);

for(int c = 0; (c = readfile.read()) != -1; )

buffer.append((char)c);

Pattern pattern = Pattern.compile(

_____________ Pattern.CASE_INSENSITIVE);

Matcher matcher =________;

while (marcher. find ())

{

int start = matcher.start();

int end = matcher.end();

String match = buffer.substring(start, end);

System.out.println (match);

}

}

catch (Exception excption)

{

System. out.println (excption. getMessage ());

}

System.exit(O);

}

}


正确答案:patternString pattern.matcher(buffer)
patternString pattern.matcher(buffer) 解析:本题考查知识点:输入输出流和正则表达式解题思路:程序首先使用InputStreamReader的实例“in”从标准输入中获取用户输入的文件名,并将结果存放在“fileName”字符串中。if语句用来判断用户输入的文件名是否为空,如果为空则退出程序,不做任何处理。然后根据文件名读取相应的文件内容存放在StringBuffer的实例“buffer”中。然后建立起与正则表达式对应的模式对象“pattem”,并与“buffer”帮定,生成一个匹配器“matcher”。最后使用while循环查找到相应的字符串。
Patter的compile方法用来将正则表达式编译成模式对象。compile方法的第一个参数是正则表达式字符串,所以第一个空的答案是“patternString”。
第二个空用来建立一个匹配器。模式对象建立匹配器的方法是matcher(string),其中string是需要做模式匹配的兑现,本题中需要做模式匹配的对象是“buffer”。


7 .string = null 和string = “”的区别


正确答案:
答:前者没有分配内存控件,后着分配了


在C#中,string str = null 与 string str = “” 请尽量使用文字或图象说明其中的区别。


正确答案:
答:string str = null 是不给他分配内存空间,而string str =  给它分配长度为空字符串的内存空间。


A pattern according to which vessels and / or aircraft may conduct a co-ordinated search is a ___________.

A.Research pattern

B.Research mode

C.Search pattern

D.Search and rescue mode


正确答案:C
船舶和航空器进行协调搜救的模式叫做搜寻模式。

更多 “咪咕文化科技有限公司11月招聘面试题191道2020119” 相关考题
考题 假设re模块已成功导入,并且有pattern=re.compile(’^’+’/.’.join([r’/d{1,3}’foriinrange(4)])+’$’),那么表达式pattern.match(’192.168.1.103’)的值为None。正确答案:错误

考题 判断题在python中,string模块有digits属性。A 对B 错正确答案:对解析:暂无解析

考题 单选题()is not a search pattern.A Williamson TurnB ParallelC SectorD zig-zag maneuver正确答案:C解析:暂无解析

考题 string模块中的属性有哪些()。A、ascii_lettersB、digitsC、inD、input正确答案:A,B

考题 正则表达式模块re的match()方法是从字符串的开始匹配特定模式,而search()方法是在整个字符串中寻找模式,这两个方法如果匹配成功则返回match对象,匹配失败则返回空值None。正确答案:正确

考题 在C#中,下列哪条语句能创建一个具有3个初始值为""的元素的字符串数组?()A、string StrList[3]("");B、string[3] StrList={"","",""};C、string[] StrList={"","",""};D、string[] StrList=new string[3];正确答案:C

考题 在python中,string模块有digits属性。正确答案:正确

考题 判断题假设re模块已成功导入,并且有pattern=re.compile(’^’+’/.’.join([r’/d{1,3}’foriinrange(4)])+’$’),那么表达式pattern.match(’192.168.1.103’)的值为None。A 对B 错正确答案:错解析:暂无解析

考题 单选题下面哪项不是response对象的方法()A set Content Type(String contentTypestr)B set Header(String headername,String headervalue)C get Parameter(String str)D send Error(int errorcode)正确答案:A解析:暂无解析

考题 假设已成功导入Python标准库string,那么表达式len(string.digits)的值为()。正确答案:10