我有一个变量,里面有大约100行。我需要打印有网址的线条。
$string = "this is just a test line 1
this is a test line 2
http://somelink1
this is line 4
http://link2
...
...
我只需要打印网址链接。
如何打印来自$string的所有线条匹配图案。尝试了下面的代码。
my $resu =~ /(http(s)?://)?([\w-]+\.)+[\w-]+(/[\w- ;,./?%&=]*)?/, $string;
print $resu;
我有一个数组列表:
List<int[]> a = new List<int[]>();
我在里面放了几个数组
int[] b = new int[3] {1, 2, 3};
int[] c = new int[4] {4, 5, 6, 7};
a.Add(b);
a.Add(c);
我怎么才能只打印List a中的b[1]呢
我们怎么才能通过使用这个词来知道哪个词存在呢?
word_list = ['hello','hi','super']
if any(word in string for word in word_list):
print('found')
通过这个,我可以遍历这些行,但无法找到它在该行中找到的单词。
示例:考虑输入中的4行
Hello samuel\n
Hi how are you\n
I’m super\n
Thanks
预期产出:
Hello,true
Hi,true
Super,true
N/a,false
但是
我需要创建函数,在调用它们时使用for循环打印出特定的模式。
def patternOne():
for k in range(numberOfRows):
for a in range(numberOfRows):
print("*", end="")
print()
def patternTwo():
for k in range(numberOfRows):
for a in range(k + 1):
print("*", e
如何打印这样的图案:
(需要打印n-1 行)
input=3
----@
--@-@-@
input=6
----------@
--------@-@-@
------@---@---@
----@-----@-----@
--@-------@-------@
我的代码:
row = int(input())
for i in range(1, row):
for j in range(1,row-i+1):
print("-", end="")
for j in range(1, 2*i):
if j==1
我需要得到一些数据,并在其他级别使用它。我不能返回(c),我在找一个图案。我怎么才能正确地返回呢?
public string AutoUpdate(string _search)
{
using (var context = new Phone_BookEntities1())
{
var c = from d in context.Cantacts
where d.Cantact1 == _search
select d.Cantact1.ToString();
return c