此题为判断题(对,错)。
请编写一个函数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;
}
在Shell变量引用操作符可实现模式匹配替换其中()用来的含义是若pattern匹配变量stra的头部,则删除最长匹配部分并返回剩余部分。
A.${strapattern}
B.${strapattern}
C.${stra%pattern}
D.${stra%%pattern}
下面的哪些程序段可能导致错误? ( ) Ⅰ: String s = "Gone with the wind"; String t = "good "; String k = s + t; Ⅱ: String s = "Gone with the wind"; String t; t = s[3] + "one"; Ⅲ: String s = "Gone with the wind"; String standard = s.toUpperCase(); Ⅳ: String s = "home directory"; String t = s-"directory":
A.Ⅱ、Ⅲ
B.Ⅱ、Ⅳ
C.Ⅰ、Ⅳ
D.Ⅲ、Ⅳ
正则表达式模块re的match()方法是从字符串的开始匹配特定模式,而search()方法是在整个字符串中寻找模式,这两个方法如果匹配成功则返回match对象,匹配失败则返回空值None。
此题为判断题(对,错)。
常见的HTTP状态码有哪些?可用的回答 : 200 OK 301 Moved Permanently 302 Found 304 Not Modified 307 Temporary Redirect 400 Bad Request 401 Unauthorized 403 Forbidden 404 Not Found 410 Gone 500 Internal Server Error 501 Not Implemented
Python里面match()和search()的区别?可用的回答 :re模块中match(pattern,string,flags),检查string的开头是否与pattern匹配。re模块中research(pattern,string,flags),在string搜索pattern的第一个匹配值。
说一说redis-scrapy中redis的作用?可用的回答 : 它是将scrapy框架中Scheduler替换为redis数据库,实现队列管理共享。 优点: 可以充分利用多台机器的带宽; 可以充分利用多台机器的IP地址。
数据库的优化?可用的回答 : 1. 优化索引、SQL 语句、分析慢查询; 2. 设计表的时候严格根据数据库的设计范式来设计数据库; 3. 使用缓存,把经常访问到的数据而且不需要经常变化的数据放在缓存中,能节约磁盘IO; 4. 优化硬件;采用SSD,使用磁盘队列技术(RAID0,RAID1,RDID5)等; 5. 采用MySQL 内部自带的表分区技术,把数据分层不同的文件,能够提高磁盘的读取效率; 6. 垂直分表;把一些不经常读的数据放在一张表里,节约磁盘I/O; 7. 主从分离读写;采用主从复制把数据库的读操作和写入操作分离开来; 8. 分库分表分机器(数据量特别大),主要的的原理就是数据路由; 9. 选择合适的表引擎,参数上的优化; 10. 进行架构级别的缓存,静态化和分布式; 11. 不采用全文索引; 12. 采用更快的存储方式,例如 NoSQL存储经常访问的数据
说一下Django,MIDDLEWARES中间件的作用?可用的回答 : 中间件是介于request与response处理之间的一道处理过程,相对比较轻量级,并且在全局上改变django的输入与输出。
scrapy的优缺点?为什么要选择scrapy框架?可用的回答 : 优点: 采取可读性更强的xpath代替正则强大的统计和log系统 同时在不同的url上爬行 支持shell方式,方便独立调试 写middleware,方便写一些统一的过滤器 通过管道的方式存入数据库 缺点: 基于python爬虫框架,扩展性比较差,基于twisted框架, 运行中exception是不会干掉reactor,并且异步框架出错后是不会停掉其他任务的,数据出错后难以察觉
Python中的lambda是什么?可用的回答 :它是一个单独的表达式匿名函数,通常用作内联函数。
scrapy和requests的使用情况?可用的回答 : requests 是 polling 方式的,会被网络阻塞,不适合爬取大量数据 scapy 底层是异步框架 twisted ,并发是最大优势
以下是替换字符串中制定字符的函数过程: Function sReplace (SearchLine As String,SearchFor As String,Replace With As String) As String Dim vSearchLine As String,found As Integer found=InStr (SearchLine,SearchFor):vSearchLine=SearchLine If found <>0 Then vSearchLine=" " If found>1 Then vSearchLine=Left (SearchLine,found -1) vSearchLine=vSearchLine+ReplaceWith End If If(表达式)<Len(SearchLine)Then vSearchLine=vSearchLine+Rights (SearchLine,Len (SearchLine) ―found―Len(SearchFor)+1) End If End If sReplace=vSeachLine End Function过程中的“表达式”应为( )。
A.found
B.found-1
C.found+Len(SearchFor)
D.found+Len(SearchFor)-1
本程序的功能是,根据用户输入的文件名,在相应的文件内容中查找匹配给定模式的字符串,并将这些字符串显示出来。模式串为“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);
}
}
在C#中,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
如须查询四字地名代码以ZB开头的机场,应在Aerodrome Code Search String中填写().