简体   繁体   English

YAML - 多次打印字符串

[英]YAML-Print string a number of times

Is there an easy way in YAML to print a string a number of times? YAML中是否有一种简单的方法可以多次打印字符串?

for example in Python例如在Python

print('String' * 500)

Can't get the syntax working in YAML无法在YAML中使用语法

You can use below to print the string say 50 times:您可以使用下面的字符串打印 50 次:

- name: Print 50 times
  hosts: localhost
  tasks:
      - name: with file
        debug: msg="This is my loop"
        with_sequence: count=50

You can read more here你可以在这里阅读更多

YAML ("YAML Ain't Markup Language") is a human-readable data-serialization language. YAML(“YAML 不是标记语言”)是一种人类可读的数据序列化语言。 It is commonly used for configuration files and in applications where data is being stored or transmitted.它通常用于配置文件和存储或传输数据的应用程序。

Its not a programming language.它不是一种编程语言。 So that I think you can solve your problem with Python's yaml library.所以我认为您可以使用 Python 的 yaml 库解决您的问题。

  1. load YAM file as Python object将 YAM 文件加载为 Python object
  2. Update the value here ('String' * 500)更新此处的值 ('String' * 500)
  3. Dump Python object to YAML file.将 Python object 转储到 YAML 文件。

https://stackabuse.com/reading-and-writing-yaml-to-a-file-in-python/ https://stackabuse.com/reading-and-writing-yaml-to-a-file-in-python/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何打印一个字符串,显示字符串中每个字符重复的次数? - how to print a string showing the number of times each character is repeated in a string? 如何编写一个递归函数来打印字符串一定次数? - How to write a recursive function to print a string a certain number of times? 如何打印字符串中每个字母出现的次数? - How can i print number of times each alphabet occurs in the string? 读取和打印字符串x次 - Reading and print string x times 带有字典的函数,该函数以字符串作为输入并计算每个字母出现的次数 - Function with dictionary that takes a string as input and counts the number of times each letter appears wont print YAML将5e-6加载为字符串而不是数字 - YAML loads 5e-6 as string and not a number Python 程序打印出提供的 Substring 的模式在提供的字符串中匹配的次数 - Python program to Print out the number of times the pattern of a provided Substring matches in a provided String 打印 substring 在 python 中从左到右出现在给定字符串中的次数 - to print the number of times that the substring occurs in the given string from left to right in python 使用Python从数组中打印N次 - Print Number N times from array with Python 如何打印两次相同的随机数? - How print two times same random number?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM