我有这段文字。我想每次发生 ● Test suite failed to run
Can't convert node without a body
at NodePath.ensureBlock (node_modules/@babel/traverse/lib/path/conversion.js:64:11)
at Scope.push (node_modules/@babel/traverse/lib/scope/index.js:727:12)
at Object.toSequenceExpression (node_modules/@babel/types/lib/converters/toSequenceExpression.js:19:11)
at NodePath.replaceExpressionWithStatements (node_modules/@babel/traverse/lib/path/replacement.js:203:36)
at NodePath.insertAfter (node_modules/@babel/traverse/lib/path/modification.js:128:17)
at NodePath.replaceWithMultiple (node_modules/@babel/traverse/lib/path/replacement.js:85:22)
at PluginPass.AssignmentExpression (node_modules/babel-preset-react-app/node_modules/@babel/plugin-transform-destructuring/lib/index.js:433:14)
at newFn (node_modules/@babel/traverse/lib/visitors.js:193:21)
at NodePath._call (node_modules/@babel/traverse/lib/path/context.js:53:20)
at NodePath.call (node_modules/@babel/traverse/lib/path/context.js:40:17)
时就找到字符串索引。
我正在使用"PO 00000"
但是它给了我findPageNum = [m.start() for m in re.finditer(pageNum, noNewLine)]
开始后20个字符的值。
这是我的代码。
"PO 00000"
输出为# -*- coding: utf-8 -*-
import re
noNewLine = ("UR IB U U E PL NU Congressional Record M S United States of America PROCEEDINGS AND DEBATES OF THE Vol. 163 115 th CONGRESS, FIRST SESSION WASHINGTON, WEDNESDAY, JUNE 7, 2017 No. 97 Senate The Senate met at 9:30 a.m. and was called to order by the Honorable RAND PAUL, a Senator from the Commonwealth of Kentucky. f PRAYER The Chaplain, Dr. Barry C. Black, offered the following prayer: Let us pray. Father of love, whose presence and power is revealed to the hearts that long for Your guidance, we thank You for the gift of this day. May we use this borrowed time for Your glory. As our lawmakers strive to honor You, may they work with commendable zeal, knowing that life’s evening is coming when their labor will be done. Lord, give them the wisdom to keep Your words in their hearts, providing them with a lamp for their feet and a light for their paths. Continue to be our strength and shield. May we think of You consistently and trust You constantly. We pray in "
"Your loving Name. Amen. f PLEDGE OF ALLEGIANCE The Presiding Officer led the Pledge of Allegiance, as follows: I pledge allegiance to the Flag of the United States of America, and to the Republic for which it stands, one nation under God, indivisible, with liberty and justice for all. f Mr. PAUL thereupon assumed the Chair as Acting President pro tempore. f RECOGNITION OF THE MAJORITY LEADER The ACTING PRESIDENT pro tempore. The majority leader is recognized. f MEASURE READ THE FIRST TIME—H.R. 1628 Mr. MCCONNELL. Mr. President, I understand there is a bill at the desk, and I ask for its first reading. The ACTING PRESIDENT pro tempore. The clerk will read the bill by title for the first time. The legislative clerk read as follows: A bill (H.R. 1628) to provide for reconciliation pursuant to title II of the concurrent resolution on the budget for fiscal year 2017. Mr. MCCONNELL. Mr. President, I now ask for a second reading and, in order to place the bill on the calendar under "
"the provisions of rule XIV, I object to my own request. The ACTING PRESIDENT pro tempore. Objection is heard. The bill will be read for the second time on the next legislative day. f APPOINTMENT OF ACTING PRESIDENT PRO TEMPORE The PRESIDING OFFICER. The clerk will please read a communication to the Senate from the President pro tempore (Mr. HATCH). The legislative clerk read the following letter: U.S. SENATE, PRESIDENT PRO TEMPORE, Washington, DC, June 7, 2017. To the Senate: Under the provisions of rule I, paragraph 3, of the Standing Rules of the Senate, I hereby lotter on DSKBCFDHB2PROD with SENATE appoint the Honorable RAND PAUL, a Senator from the Commonwealth of Kentucky, to perform the duties of the Chair. ORRIN G. HATCH, President pro tempore. SANCTIONS LEGISLATION Mr. MCCONNELL. Mr. President, Senators today will have an opportunity to advance important bipartisan Iran sanctions legislation. As we consider this bill, we anticipate that amendments addressing Russia "
"sanctions are likely to be offered. I am encouraged that the chairmen of the Foreign Relations and Banking Committees, Senator CORKER and Senator CRAPO, have already been in discussions with their respective ranking members to work toward a bipartisan agreement. I support that effort, and I will have more to say about the underlying legislation tomorrow. f INFRASTRUCTURE Mr. MCCONNELL. Now, Mr. President, on one other matter, later today President Trump will visit Cincinnati to discuss the importance of our Nation’s inland waterways. Kentucky is home to over 1,900 miles of navigable inland waterways, which, in addition to adding majestic beauty to my State, are also vital to thousands of jobs in the Commonwealth. In recent years, over 95 million tons of cargo and agricultural products have been transported across these water trade routes. Our many levees, docks, and dams represent crucial infrastructure that play an important role in our regional and national economy. I am proud "
"of the work Congress has done in the past to protect our Nation’s waterways, like passing the Water Resources Development Act by a bipartisan majority last year in order to support infrastructure, enhance commerce, and maintain American ecosystems. As President Trump continues to release his plans for our Nation’s infrastructure, I look forward to working with the administration and colleagues in the Senate to protect and improve the many roads, bridges, airports, and waterways that serve people and jobs all across our country. f ORDER OF PROCEDURE Mr. MCCONNELL. Mr. President, I ask unanimous consent that notwithstanding rule XXII, the cloture vote on the motion to proceed to S. 722 occur at 1:45 p.m. today, and if cloture is invoked, time postcloture count as if invoked at 10:30 a.m. The ACTING PRESIDENT pro tempore. Without objection, it is so ordered. ∑ This ‘‘bullet’’ symbol identifies statements or insertions which are not spoken by a Member of the Senate on the floor. "
"S3301 . VerDate Sep 11 2014 23:29 Jun 07, 2017 Jkt 069060 PO 00000 Frm 00001 Fmt 0624 Sfmt 0634 E:\CR\FM\A07JN6.000 S07JNPT1 PO 00000 Frm 00001 Fmt 0637 Sfmt 0634 E:\CR\FM\A05JN6.000 S05JNPT1")
pageNum = "PO 00000"
findPageNum = [m.start() for m in re.finditer(pageNum, noNewLine)]
print(findPageNum)
。应该是[5040, 5112]
。
答案 0 :(得分:3)
您似乎认为您使用的是Python 3,但您使用的是Python2。(无论如何,您正在编写print
调用,就像您认为自己使用的是Python 3。)
在Python 2上,您的字符串是一个字节字符串,而您正在使用一个字节字符串正则表达式。所有索引都是按字节而不是字符。您的字节字符串包含Unicode字符以外的Unicode字符的多字节UTF-8编码,从而导致索引与您期望的值不同。
获取Python 3。